package 练习;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author Mucd
 * @ClassName Anti
 * @Date 2020/12/12/012
 * @Specification Alibaba
 */
public class Anti {
    public static void main(String[] args) {
/*        Scanner sc = new Scanner(System.in);
        //定义5个长度数组
        int[] arr = new int[5];
        for (int i = 0; i < arr.length; i++) {
            System.out.println("输入第" + (i + 1) + "个数");
            arr[i] = sc.nextInt();
        }
        System.out.println("反转前:" + Arrays.toString(arr));
        //start 用来表示左边的数  end数组最大索引  左边的值数量小于等于右边值数量
        //start从左往右 ＋  end从右往左 -
        for (int start = 0, end = arr.length-1; start <= end; start++, end--) {
            //小值赋给 temp
            int temp = arr[start];
            //把最右边的值给左边的值
            arr[start] = arr[end];
            //把最左边的值给右边
            arr[end] = temp;

        }
        System.out.println("反转后"+Arrays.toString(arr));*/
        int[] arrays = new int[5];
        anti(arrays);
    }

    public static void anti(int[] arr) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入5个要反转的数");
        //接收数字
        for (int i = 0; i < arr.length; i++) {
            System.out.println("输入第" + (i + 1) + "个");
            arr[i] = sc.nextInt();
        }
        System.out.println("反转前: "+Arrays.toString(arr));
        //home最左面从左往右 ++  end最右从右往左 --
        for (int home = 0, end = arr.length - 1; home <= end; home++, end--) {
            //最小值给 temp
            int temp = arr[home];
            //最右边给最左边
            arr[home] = arr[end];
            //最小值给end值
            arr[end] = temp;
        }
        System.out.println("反转后: "+ Arrays.toString(arr));
    }
}